{block #mainTitle}Sanita{/block}
{block #content}
<div id="dialog-confirm" style="display:none;">
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;">
        </span>Opravdu si přejete položku trvale odstranit?
    </p>
</div>

<div id="breadcrumb">
    <span class="breadcrumb">Vzorkovna</span>
</div>

<a class="button-add" href="{link Sanita:pridat}">Přidat</a>   
<table class="data-table" n:if="count($sanitary)">    
    <thead>
        <tr>
            <th>Id</th>
            <th>Název</th>            
            <th>Výrobce</th>
            <th>Série</th>
            <th>Cena</th>
            <th>Akce</th>
        </tr>
    </thead>
    <tbody>        
        <tr n:foreach="$sanitary as $item">
            <td>{$item->id_sanitary}</td>
            <td>{$item->title}</td>
            <td>{$item->manufacturer->title}</td>
            <td>{$item->series}</td>
            <td>{$item->price|number:2:',':' '} Kč</td>
            <td>
                <a class="action-icon-edit" href="{link upravit $item->id_sanitary}">upravit</a>
                <a class="action-icon-image" href="{link obrazky $item->id_sanitary}">obrázky</a>
                {if $item->published}
                <a class="ajax action-icon-unpublish" href="{link stahnout! $item->id_sanitary}">stáhnout z webu</a>
                {else}
                <a class="ajax action-icon-publish" href="{link zverejnit! $item->id_sanitary}">zveřejnit</a>
                {/if}
                <a class="action-icon-delete" href="{link smazat! $item->id_sanitary}">smazat</a>
            </td>
        </tr>        
    </tbody>    
</table>
<script type="text/javascript">
    // TODO: modalni dialog jako funkce
    initButtons();
    initAjaxLinks();

    $(function() {
        $(".action-icon-delete").bind('click', showModal);
        function showModal() {
            var link = this.href;                
            $('#dialog-confirm').dialog({
                    modal: true,
                    closeText: 'zavřít',
                    title: 'Smazání položky sanity',
                    buttons: {
                        'Ano':function(event) {
                            event.preventDefault();
                            $.get(link);
                            $(this).dialog('close');
                        },
                        'Ne': function() {
                            $(this).dialog('close');
                        }
                    }
            });
            return false;
        };
    });
</script>
{/block}
